###############################################
#Figure 3: Risk Type and Social Spending 
#Author: Raluca L. Pahontu
###############################################

mydata <- read.dta13("shp.dta", convert.factors = FALSE)
mydata$rho <- factor(mydata$rho, levels=c(1,2,3))
fig3 <- ggplot(mydata, aes(rho, social_spending)) +
  stat_summary(fun=mean, geom="bar", width=.5, fill="gray85", position= "dodge",  color="gray85") +
  stat_summary(fun.data =mean_cl_normal, geom="errorbar", width=.07, size=.8, color="black",
               position=position_dodge(width = .5))  +
  theme(panel.background = element_blank(),
        panel.grid.major = element_line(linetype = "dotted", size=.4, colour="grey90"),
        panel.grid.minor = element_line(linetype = "dotted", size=.4, colour="grey90"),
        axis.line.y = element_line(colour = "Black", linetype = "solid"),
        axis.ticks.length=unit(0.3,"cm"),
        axis.text = element_text(colour ="black", size=14),
        axis.title = element_text(size=16),
        axis.ticks.x = element_blank()) + 
  ylab("Average Social Spending (%)\n") +   xlab("\n Type") + 
  scale_x_discrete(breaks = c(3,2,1),  
                   labels= c(expression(paste(rho, 1)),expression(paste(rho,2)), expression(paste(rho,3))), 
                   limits=c("3", "2", "1")) +
  scale_y_continuous(limits = c(.4,.8),  expand = c(0,0), oob=rescale_none) +
  coord_cartesian(ylim=c(.4,.8)) 
ggsave("figure3.pdf")



